<?php

namespace App\Models\OpenShop\InvestmentPromotion;

use App\Models\BaseModel;
use DateTimeInterface;

class OpenShopPreparationOrderRefundModel extends BaseModel
{
    protected $table = 'open_shop_preparation_order_refund_stream';


    protected $fillable = [
        'orderNo',
        'preparationNo',
        'refundSerialNo',
        'money',
        'type',
        'refundType',
        'remark',
        'refuseRemark',
        'status',
        'isDeleted',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedAtByUid',
    ];

    protected $appends = [
        'typeText',
        'statusType'
    ];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format("Y-m-d H:i:s");
    }


    const ORDER_TYPE_0 = 0;
    const ORDER_TYPE_1 = 1;
    const ORDER_TYPE_2 = 2;
    const ORDER_TYPE_3 = 3;
    const ORDER_TYPE_4 = 4;

    const CN_ORDER_REFUND_TYPE = [
        self::ORDER_TYPE_0 => '设计费',
        self::ORDER_TYPE_1 => '商户通',
        self::ORDER_TYPE_2 => '软装报价',
        self::ORDER_TYPE_3 => '装修保证金',
        self::ORDER_TYPE_4 => '超标设计费',
    ];

    const SOFT_LIST = [
        self::ORDER_TYPE_2,
    ];

    const DESIGN_LIST = [
        self::ORDER_TYPE_0,
        self::ORDER_TYPE_1,
        self::ORDER_TYPE_4,
    ];

    const FIT_LIST = [
        self::ORDER_TYPE_3,
    ];

    const ORDER_REFUND_TYPE_0 = 0;

    const CN_PAY_STATUS = [
        self::ORDER_REFUND_TYPE_0 => '手动记录',
    ];

    const ORDER_STATUS_0 = 0;
    const ORDER_STATUS_1 = 1;
    const ORDER_STATUS_2 = 2;

    const CN_STATUS = [
        self::ORDER_STATUS_0 => '未退款',
        self::ORDER_STATUS_1 => '已退款',
        self::ORDER_STATUS_2 => '拒绝退款',
    ];

    public function getTypeTextAttribute()
    {
        if (in_array($this->type, self::DESIGN_LIST)) {
            return "设计模块";
        } elseif (in_array($this->type, self::SOFT_LIST)) {
            return "软装模块";
        } elseif (in_array($this->type, self::FIT_LIST)) {
            return "装修保证金";
        } else {
            return "其他模块";
        }
    }

    public function getStatusTypeAttribute()
    {
        return self::CN_STATUS[$this->status];
    }
}
